package com.hmall.web;

import com.hmall.common.dto.PageDTO;
import com.hmall.pojo.ItemCondition;
import com.hmall.pojo.ItemConditionVo;
import com.hmall.service.SearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description SearchController
 * @Author luohai
 * @Date 2024-11-15
 */
@RestController
@Slf4j
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private SearchService searchService;

    @PostMapping("/filters")
    public ItemConditionVo getBrandAndCategory(@RequestBody ItemCondition itemCondition){
        return searchService.getBrandAndCategory(itemCondition);
    }

    /**
     * 基本搜索功能
     * @param itemCondition
     * @return
     */
    @PostMapping("/list")
    public PageDTO query(@RequestBody ItemCondition itemCondition){
        return searchService.query(itemCondition);
    }
}
